package test;

import com.example.excel.ExcelRead;
import com.example.excel.pojo.BaseExcel;
import com.example.excel.pojo.BaseRow;
import com.example.excel.pojo.BaseSheet;
import com.example.excel.resolve.ExcelResolveAnnotationImpl;
import com.example.excel.resolve.ExcelResolveEachListener;
import com.example.excel.resolve.ExcelResolveListImpl;

import java.util.List;

public class MainText {

    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();

        String filePath = ExcelRead.class.getResource("/xlsx/test-Excel.xlsx").getPath();

//        ExcelResolveEachListener<Object> listener = ExcelResolveAnnotationImpl.create(UserInfo.class, StudentInfo.class);
//        listener.setFormatListener(new TestFormatListener());
//        BaseExcel<Object> data = ExcelRead.read( filePath, listener);
////        listener.clear();
//        for (BaseSheet<Object> sheets : data.getSheetList()) {
//            System.out.println("\n====================  "+sheets.getSheetName()+"  ==================================\n");
//            for (BaseRow<Object> row : sheets.getRowList()) {
//                System.out.println(row.getRowData().toString());
//            }
//        }

        ExcelResolveEachListener<List<String>> listener = new ExcelResolveListImpl();
        listener.setFormatListener(new TestFormatListener());
        BaseExcel<List<String>> data = ExcelRead.read( filePath, listener);
//        listener.clear();
        for (BaseSheet<List<String>> sheets : data.getSheetList()) {
            System.out.println("\n====================  "+sheets.getSheetName()+"  ==================================\n");
            for (BaseRow<List<String>> row : sheets.getRowList()) {
                System.out.println(row.getRowData().toString());
            }
        }

        System.out.println("耗时："+(System.currentTimeMillis()-startTime)+"ms");
    }
}
